-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate the Shopper Renew Subscription E2E test to Playwright #10144
Migrate the Shopper Renew Subscription E2E test to Playwright #10144
Conversation
await navigation.goToSubscriptions( page ); | ||
|
||
if ( ! subscriptionId ) { | ||
throw new Error( 'Subscription ID is not set' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this throw
to provide a better error in case the previous test fails. We can remove it if not desired.
export const shouldRunSubscriptionsTests = | ||
process.env.SKIP_WC_SUBSCRIPTIONS_TESTS !== '1'; | ||
|
||
export const products = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure about the names of those constants. I wanted to use SHOULD_RUN_SUBSCRIPTIONS_TESTS
and PRODUCTS
, but since ESLint flagged it, I opted to keep both in lower camel case for now.
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: 0 B Total Size: 1.36 MB ℹ️ View Unchanged
|
tests/e2e-pw/utils/rest-api.ts
Outdated
* @param {string} emailAddress Customer user account email address. | ||
* @return {Promise<void>} | ||
*/ | ||
export const deleteCustomerByEmailAddress = async ( emailAddress: string ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent quite some time troubleshooting this issue. I initially tried using the function from WC's test utils, which is used by the Puppeteer tests, but consistently encountered the following error:
Error: Configuration property "url" is not defined
at Config.get (/woopayments/node_modules/@woocommerce/e2e-utils/node_modules/config/lib/config.js:182:11)
at Object.<anonymous> (/Users/ronrennick/Sites/solaris/woocommerce/packages/js/e2e-utils/src/factories.js:8:23)
at Object.<anonymous> (/Users/ronrennick/Sites/solaris/woocommerce/packages/js/e2e-utils/src/index.js:8:1)
at Object.<anonymous> (/woopayments/tests/e2e-pw/specs/shopper/shopper-myaccount-renew-subscription.spec.ts:6:25)
I attempted to resolve this by adding default.json
and test.json
with the required keys to the e2e-pw/config
folder, following the existing pattern, but it didn’t work. After trying multiple approaches without success, I ended up duplicating the original function and modifying it to work on our setup.
let page: Page; | ||
|
||
test.beforeAll( async ( { browser }, { project } ) => { | ||
const restApi = new RestAPI( project.use.baseURL ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're using project.use.baseURL
to get the same base URL Playwright is using while running the tests.
I've run the tests 3 times, and I'm getting this error:
and the screenshot shows: Maybe that's something wrong with my local setup. Also I get this warning:
|
…myaccount-renew-subscription-e2e-test
Thanks for running the tests, @tpaksu! I’d recommend resetting your E2E environment and running
Most of the tests get the warning because the whole spec takes more than X seconds (what it considers slow). Unfortunately, in this case, the tests are co-dependent so we couldn't do something like that. |
@eduardoumpierre I've done those as they are mentioned in the testing instructions :) I've also run |
Thanks for letting me know! I’ll try a different approach to have the checkout form ready for submission. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, the E2E tests on my local also passed, turns out that my site had card testing prevention enabled, which gave the error on my previous comment. Disabling the flag and refreshing the cache let the renewal pass through. But as we talked on Slack, we should better check if the card testing prevention token is being rendered on the renewal checkout page, as it shouldn't be failing. Maybe we can extend the tests to test the card testing prevention tokens too in a different issue.
Thanks for working on this, we can ship it!
Fixes #10084
Changes proposed in this Pull Request
This PR aims to migrate the "Subscriptions > Renew a subscription in my account" spec to Playwright, removing the corresponding test from the Puppeteer test suite.
Testing instructions
npm run test:e2e-reset
npm run test:e2e-setup
npm run test:e2e-pw shopper-myaccount-renew-subscription
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge